﻿using System;
using LuaInterface;

public class UEngine_GameEventWrap
{
	public static void Register(IntPtr L)
	{
		LuaMethod[] regs = new LuaMethod[]
		{
			new LuaMethod("New", _CreateUEngine_GameEvent),
			new LuaMethod("GetClassType", GetClassType),
		};

		LuaField[] fields = new LuaField[]
		{
			new LuaField("m_gameEventParam", get_m_gameEventParam, set_m_gameEventParam),
			new LuaField("m_gameEventDelegate", get_m_gameEventDelegate, set_m_gameEventDelegate),
		};

		LuaScriptMgr.RegisterLib(L, "UEngine.GameEvent", typeof(UEngine.GameEvent), regs, fields, null);
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int _CreateUEngine_GameEvent(IntPtr L)
	{
		LuaScriptMgr.CheckArgsCount(L, 0);
		UEngine.GameEvent obj = new UEngine.GameEvent();
		LuaScriptMgr.PushValue(L, obj);
		return 1;
	}

	static Type classType = typeof(UEngine.GameEvent);

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int GetClassType(IntPtr L)
	{
		LuaScriptMgr.Push(L, classType);
		return 1;
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int get_m_gameEventParam(IntPtr L)
	{
		object o = LuaScriptMgr.GetLuaObject(L, 1);

		if (o == null)
		{
			LuaTypes types = LuaDLL.lua_type(L, 1);

			if (types == LuaTypes.LUA_TTABLE)
			{
				LuaDLL.luaL_error(L, "unknown member name m_gameEventParam");
			}
			else
			{
				LuaDLL.luaL_error(L, "attempt to index m_gameEventParam on a nil value");
			}
		}

		UEngine.GameEvent obj = (UEngine.GameEvent)o;
		LuaScriptMgr.PushValue(L, obj.m_gameEventParam);
		return 1;
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int get_m_gameEventDelegate(IntPtr L)
	{
		object o = LuaScriptMgr.GetLuaObject(L, 1);

		if (o == null)
		{
			LuaTypes types = LuaDLL.lua_type(L, 1);

			if (types == LuaTypes.LUA_TTABLE)
			{
				LuaDLL.luaL_error(L, "unknown member name m_gameEventDelegate");
			}
			else
			{
				LuaDLL.luaL_error(L, "attempt to index m_gameEventDelegate on a nil value");
			}
		}

		UEngine.GameEvent obj = (UEngine.GameEvent)o;
		LuaScriptMgr.Push(L, obj.m_gameEventDelegate);
		return 1;
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int set_m_gameEventParam(IntPtr L)
	{
		object o = LuaScriptMgr.GetLuaObject(L, 1);

		if (o == null)
		{
			LuaTypes types = LuaDLL.lua_type(L, 1);

			if (types == LuaTypes.LUA_TTABLE)
			{
				LuaDLL.luaL_error(L, "unknown member name m_gameEventParam");
			}
			else
			{
				LuaDLL.luaL_error(L, "attempt to index m_gameEventParam on a nil value");
			}
		}

		UEngine.GameEvent obj = (UEngine.GameEvent)o;
		obj.m_gameEventParam = (UEngine.GameEventParam)LuaScriptMgr.GetNetObject(L, 3, typeof(UEngine.GameEventParam));
		LuaScriptMgr.SetValueObject(L, 1, obj);
		return 0;
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int set_m_gameEventDelegate(IntPtr L)
	{
		object o = LuaScriptMgr.GetLuaObject(L, 1);

		if (o == null)
		{
			LuaTypes types = LuaDLL.lua_type(L, 1);

			if (types == LuaTypes.LUA_TTABLE)
			{
				LuaDLL.luaL_error(L, "unknown member name m_gameEventDelegate");
			}
			else
			{
				LuaDLL.luaL_error(L, "attempt to index m_gameEventDelegate on a nil value");
			}
		}

		UEngine.GameEvent obj = (UEngine.GameEvent)o;
		LuaTypes funcType = LuaDLL.lua_type(L, 3);

		if (funcType != LuaTypes.LUA_TFUNCTION)
		{
			obj.m_gameEventDelegate = (UEngine.GameEventDelegate)LuaScriptMgr.GetNetObject(L, 3, typeof(UEngine.GameEventDelegate));
		}
		else
		{
			LuaFunction func = LuaScriptMgr.ToLuaFunction(L, 3);
			obj.m_gameEventDelegate = (param0) =>
			{
				int top = func.BeginPCall();
				LuaScriptMgr.PushValue(L, param0);
				func.PCall(top, 1);
				func.EndPCall(top);
			};
		}
		LuaScriptMgr.SetValueObject(L, 1, obj);
		return 0;
	}
}

